package com.example.project.repository;

import com.example.project.model.FAQ;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

public interface FAQRepository extends JpaRepository<FAQ, Integer> {
    // 根据category_id查询FAQ
    List<FAQ> findByCategoryId(int categoryId); // 根据category_id查询FAQ
    // 根据搜索关键词查询 FAQ
    @Query("SELECT f FROM FAQ f WHERE LOWER(f.question) LIKE LOWER(CONCAT('%', :search, '%'))")
    List<FAQ> findByQuestionContainingIgnoreCase(@Param("search") String search); // 根据搜索关键词查询 FAQ
}